home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / CLLZW.HPP < prev    next >
C/C++ Source or Header  |  1993-05-30  |  3KB  |  104 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    cllzw.hpp
  5. //   Title:    C++ Class Libraries
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //    This module contains code for the class CL_LZW.
  24. //
  25. //    The code in this module may be written in C++ or C.
  26. //
  27. //    This module is portable to:
  28. //        DOS 3.X+
  29. //        MS Windows 3.X+
  30. //        OS/2 2.X+
  31. //        OS/2 2.0 PM
  32. //
  33. //    The following compilers are supported:
  34. //        MSC 6.0A
  35. //        MSC/C++ 7.0
  36. //        Borland C++ 3.1 for DOS
  37. //        Borland C++ 1.0 for OS/2 2.X
  38. //
  39. //----------------------------------------------------------------------------
  40.  
  41. //----------------------------------------------------------------------------
  42. //    Constants and structures
  43. //----------------------------------------------------------------------------
  44. #define LZW_SYMBOLS    (4096)                // Maximum sybols (0-255 are ASCII)
  45.  
  46. struct LZW_SYM                                    // Symbol
  47. {
  48.     SIZET cLen;                                    // Length of expanded symbol in bytes
  49.     SHORT sFirst;                                // First symbol in string
  50.     SHORT sNext;                                // Next string starting with same char
  51.     SHORT sSym[2];                                // Composite Symbol
  52. };
  53.  
  54. typedef VOID (FN_E *PFNLZW)(LONG, LONG);
  55.  
  56. //----------------------------------------------------------------------------
  57. //    Class CL_LZW
  58. //----------------------------------------------------------------------------
  59. CLASSDEF(CL_LZW);
  60. #define CL_LZW_PARENT CL_OBJECT
  61. class CLASSTYPE CL_LZW : public CL_LZW_PARENT
  62. {
  63.     SIZET cSym;
  64.     LZW_SYM asym[LZW_SYMBOLS];
  65.     PBYTE pbIn;
  66.     SIZET cbIn;
  67.     PBYTE pbOut;
  68.     SIZET cbOut;
  69.     SIZET cbData;
  70.     SIZET cBitsLeft;
  71.     SIZET cBits;
  72.  
  73. public:
  74.     FN_M CL_LZW();
  75.     FN_M CL_LZW(RCCL_LZW);
  76.     virtual FN_M ~CL_LZW();
  77.  
  78.     SIZET FN_M Decode(PBYTE, SIZET, PBYTE, SIZET);
  79.     BOOL FN_M DecodeFile(PCSZ, PCSZ = NULL, PFNLZW = NULL);
  80.     virtual BOOL FN_M Destroy(BOOL = TRUE);
  81.     SIZET FN_M Encode(PBYTE, SIZET, PBYTE, SIZET);
  82.     BOOL FN_M EncodeFile(PCSZ, PCSZ = NULL, PFNLZW = NULL);
  83.     virtual BOOL FN_M Initialize(SHORT = CL_INIT_ALL);
  84.     RCCL_LZW FN_M operator=(RCCL_LZW);
  85.     virtual BOOL FN_M Retrieve(PCSZ, PCSZ = NULL);
  86.     virtual BOOL FN_M Store(PCSZ, PCSZ = NULL);
  87.  
  88. #if COMPILE_DEBUG
  89.     static BOOL FN_M Test(SHORT = 0);
  90. #endif
  91.  
  92. protected:
  93.  
  94. private:
  95.     VOID FN_M Add(SHORT, SHORT);
  96.     BOOL FN_M Expand(SHORT);
  97.     BOOL FN_M IsMatch(PBYTE, SHORT);
  98.     SHORT FN_M Read();
  99.     BOOL FN_M Write(SHORT);
  100. };
  101. //----------------------------------------------------------------------------
  102. //------------------------------- End of File --------------------------------
  103. //----------------------------------------------------------------------------
  104.